<template>
	<view class="content">
		<z-paging ref="paging" v-model="formList" @query="get_form_list" :default-page-size="20">
			<template slot="top">
				<view class="bartop"></view>
				<view class="cu-bar">
					<view class="action">
						<text class="cuIcon-back text-gray" @tap="goBack"></text> 返回
					</view>
					<view class="text-lg text-bold">
						半成品支领
					</view>
					<view class="action">
						<!-- <text class="text-lg" style="color: #13227a;" @tap="createForm">新建</text> -->
					</view>
				</view>
			</template>

			<view v-if="formList.length>0" class="cu-list menu">
				<view v-for="(item,index) in formList" :key="index" @click="changeStatus(item)" class="cu-item"
					:style="index%2==0?'background:#fff':'background:#dedede' ">
					<view class="item margin-top-sm">
						<text>支领单编号：{{item.zlnumber}}</text>
						<text>备货状态：{{item.hstate}}</text>
					</view>
					<view class="item margin-bottom-sm">
						<text>领料人：{{item.name}} </text>
						<text>领料状态：{{item.lstate}}</text>
						<text>组装状态：{{item.zstate}}</text>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// "id": null, // id
				// "class": null, //班次
				// "order_id": null, //订单号
				// "product_id": null, //产品名称
				// "number": null, //机台编号
				// "unit": null, //单位
				// "material_id": null, //用料
				// "colour_id": null, //颜色/色粉
				// "order_number": null, //排产数量
				// "qualified_quantity": null, //生产合格数量
				// "working_hours": null, //实际生产工时
				// "scrapped_part": null, //残品数量
				// "operator": null, //操作工
				// "accumulate_number": null, //合格累计数量
				// "debugging_time": null, //换模调试时间
				// "change_material_time": null, // 换料烘料时间
				// "weight": null, //产品单重
				// "abnormal_time": null, //其他异常事件
				// "remarks": null, //备注
				formList: []
			}
		},
		methods: {

			onShow() {
				this.$refs.paging.reload()
			},

			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			get_form_list(pageNo, pageSize) {
				this.$Request.getPHP(this.$httpApi.claim.list + "?page=" + pageNo + "&listRows=" + pageSize).then(
					res => {
						if (res.code != 200) {
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2000
							});
						} else {
							console.log(res)
							try {
								uni.hideLoading()
								this.$refs.paging.complete(res.data.data)
							} catch (e) {
								this.$refs.paging.complete([])
								uni.hideLoading()
							}
						}
					})
			},

			changeStatus(item) {
				let url = this.$httpApi.claim.edit + "?id=" + item.id + "&bhstate=1" + "&roleid=" + this.$cache.get(
					"roleId")
				this.$Request.postPHP(url).then(
					res => {
						if (res.code != 200) {
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2000
							});
						} else {
							console.log(res)
							this.$refs.paging.reload()

						}
					})
			},

			createForm() {
				uni.navigateTo({
					url: '/pages/report_form/report_form'
				})
			}
		}
	}
</script>

<style>
	.cu-list.menu>.cu-item {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.item {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
</style>
